package avicit.im.lantop.employeeshortcutkeys.service.impl;

import avicit.im.lantop.employeeshortcutkeys.domain.EmployeeShortcutKeys;
import avicit.im.lantop.employeeshortcutkeys.service.EmployeeshortcutService;
import avicit.platform6.core.domain.BeanBase;
import avicit.platform6.core.exception.DaoException;
import avicit.platform6.core.jdbc.JdbcAvicit;
import avicit.platform6.core.service.ServiceBase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EmployeeshortcutServiceImpl extends ServiceBase implements EmployeeshortcutService {

    @Autowired
    private JdbcAvicit jdbcAvicit;

    /**
     * 获取所有的首页快捷键数据
     * @return
     * @throws Exception
     */
    @Override
	public List<Map<String, Object>> getEmpItem() throws Exception {
        List<Map<String, Object>> maps = jdbcAvicit.getJdbcTemplate().queryForList("SELECT ID,SHORTCUT_KEY_NAME,LINK_ADDRESS,SHORTCUT_KEY_PICTURE FROM LANTOP_USER_EMPLOYEE");
        return  maps;
    }

    /**
     * 根据Id获取快捷键数据
     * @param id
     * @return
     * @throws Exception
     */
    @Override
	public EmployeeShortcutKeys getEmpItemById(String id) throws Exception {
        EmployeeShortcutKeys em = this.hibernateDao.get(EmployeeShortcutKeys.class, id);
        return em;
    }


    @Override
	public  void  updateEmpItemById(EmployeeShortcutKeys em)throws  Exception{
        try {
        	  String sql="UPDATE LANTOP_USER_EMPLOYEE SET SHORTCUT_KEY_NAME='"+em.getShortcutKeyName()+"',LINK_ADDRESS='"+em.getLinkAddress()+"',SHORTCUT_KEY_PICTURE='"+em.getShortcutKeyPicture()+"' WHERE ID='"+em.getID()+"'";
              jdbcAvicit.getJdbcTemplate().update(sql);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    
    @Override
    public List<Map<String, Object>> getEmp() throws Exception {
        List<Map<String, Object>> maps = jdbcAvicit.getJdbcTemplate().queryForList("SELECT ID,SHORTCUT_KEY_NAME,LINK_ADDRESS,SHORTCUT_KEY_PICTURE FROM LANTOP_USER_EMPLOYEE WHERE LINK_ADDRESS IS NOT NULL AND  SHORTCUT_KEY_PICTURE IS NOT NULL");
        return  maps;
    }

    @Override
    public void insert(BeanBase beanBase) throws DaoException {

    }

    @Override
    public void delete(BeanBase beanBase) throws DaoException {

    }

    @Override
    public void update(BeanBase beanBase) throws DaoException {

    }
}
